/**
 * 将时间转换成更为清晰的文字说明
 * @param {Number} date 需要转换的时间戳
 */

export const timeTransform = (date) => {
    if (isNaN(Number(date))) {
      return 'date参数格式错误！'
    }
    let currentDate = new Date(Number(date))
    let differenceDate = new Date().getTime() - Number(date)
    if (differenceDate < 60 * 1000) {
        currentDate = (differenceDate / 1000).toFixed(0) + '秒前'
    } else if (differenceDate < 60 * 60 * 1000) {
        currentDate = (differenceDate / 60 / 1000).toFixed(0) + '分钟前'
    } else if (differenceDate < 60 * 60 * 24 * 1000) {
        currentDate = (differenceDate / 60 / 60 / 1000).toFixed(0) + '小时前'
    } else if (differenceDate < 60 * 60 * 24 * 10 * 1000) {
        currentDate = (differenceDate / 60 / 60 / 24 / 1000).toFixed(0) + '天前'
    } else {
        currentDate = currentDate.getFullYear() + '年' + (currentDate.getMonth() + 1) + '月' + currentDate.getDate() + '日'
    }
    return currentDate
}